package cn.itcast.bos.service.base.Impl;

import cn.itcast.bos.Dao.base.AreaDao;
import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.service.base.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2017/7/21.
 */
@Service
@Transactional
public class AreaServiceImpl implements AreaService {
    //注入dao
    @Autowired
    private AreaDao areaDao;

    @Override
    //批量插入
    public void save(List<Area> areas) {
        areaDao.save(areas);
    }

    @Override
    public Page<Area> pageQuery(Specification specification, Pageable pageable) {

        return areaDao.findAll(specification,pageable);
    }

    @Override
    //插入单个数据
    public void save(Area area) {
        areaDao.save(area);
    }

    @Override
    public void del(String[] idArray) {
        //便利数组,进行删除
        for(String id : idArray){
            areaDao.del(id);
        }
    }

    @Override
    public List<Area> findAll() {

        return areaDao.findAll();
    }
}
